package org.nepu.scr.indexrate.converter.compliancerate.differencerate;

import cn.hutool.json.JSONUtil;
import org.nepu.scr.indexrate.vo.compliancerate.differencerate.NonDestructiveInspection;

import javax.persistence.AttributeConverter;
import javax.persistence.Convert;

@Convert
public class NonDestructiveInspectionConverter implements AttributeConverter<NonDestructiveInspection, String> {
    @Override
    public String convertToDatabaseColumn(NonDestructiveInspection nonDestructiveInspection) {
        return JSONUtil.toJsonStr(nonDestructiveInspection);
    }

    @Override
    public NonDestructiveInspection convertToEntityAttribute(String s) {
        return JSONUtil.toBean(s, NonDestructiveInspection.class);
    }
}
